﻿using System;

public abstract class Shape
{
    public abstract bool IsValid { get; }
    public abstract double Area { get; }
}

public class Rectangle : Shape 
{
    private double length;
    private double width;

    public Rectangle(double length, double width)
    {
        this.length = length;
        this.width = width;
    }

    public override double Area
    {
        get
        {
            if (!IsValid)
            {
                return 0;
            }
            return length * width;
        }
    }

    public override bool IsValid
    {
        get
        {
            return length > 0 && width > 0;
        }
    }
}

public class Square : Shape
{
    private double side;
    public Square(double side)
    {
        this.side = side;
    }
    public override double Area
    {
        get
        {
            if (!IsValid)
            {
                return 0;
            }
            return side * side;
        }
    }
    public override bool IsValid
    {
        get
        {
            return side > 0;
        }
    }
}

public class Triangle : Shape
{
    private double side1;
    private double side2;
    private double side3;

    public Triangle(double side1, double side2, double side3)
    {
        this.side1 = side1;
        this.side2 = side2;
        this.side3 = side3;
    }

    public override double Area
    {
        get
        {
            if (!IsValid)
            {
                return 0;
            }
            double s = (side1 + side2 + side3) / 2;
            return Math.Sqrt(s * (s - side1) * (s - side2) * (s - side3));
        }
    }

    public override bool IsValid
    {
        get
        {
            return side1 > 0 && side2 > 0 && side3 > 0 &&
                   side1 + side2 > side3 &&
                   side1 + side3 > side2 &&
                   side2 + side3 > side1;
        }
    }
}

class Program
{
    static void Main()
    {
        Rectangle rectangle = new Rectangle(2, 10);
        Console.WriteLine($"Rectangle Area: {rectangle.Area}, Is Valid: {rectangle.IsValid}");

        Square square = new Square(11);
        Console.WriteLine($"Square Area: {square.Area}, Is Valid: {square.IsValid}");

        Triangle triangle = new Triangle(3, 4, 5);
        Console.WriteLine($"Triangle Area: {triangle.Area}, Is Valid: {triangle.IsValid}");
    }
}